package org.opens.guava.utilites.eventBus.events;

import com.google.common.eventbus.EventBus;
import org.junit.Test;
import org.opens.guava.utilites.eventBus.listeners.MultipleEventListeners;

public class MultipleEventBusExample {

    /**
     * 功能:
     *      测试一个监听器中有两个参数相同的监听方法会发生什么.
     * 输出:
     *      12:24:55.861 [main] INFO org.opens.guava.utilites.eventBus.listeners.SimpleListener - the event is: [I am String], by task1
     *      12:24:55.861 [main] INFO org.opens.guava.utilites.eventBus.listeners.SimpleListener - the event is: [I am String], by task3
     *      12:24:55.861 [main] INFO org.opens.guava.utilites.eventBus.listeners.SimpleListener - the event is: [999], by task2
     * 说明:
     *      1. eventBus.post("I am String");这一条指令触发了一个监听器中的两个方法.
     */
    @Test
    public void test1() {
        final EventBus eventBus = new EventBus();
        eventBus.register(new MultipleEventListeners());
        eventBus.post("I am String");
        eventBus.post(999);
    }

}
